home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / CK-DIGIT.DMO < prev    next >
Text File  |  1996-07-04  |  3KB  |  58 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-12-05 ╟─╖
  5.  │  │ FILE NAME   CK-DIGIT.DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC
  22.  
  23. COLOR 7, 0
  24. CLS
  25.  
  26. ? "┌───────────────────────────────────────────────────────────────────────"
  27. ? "│ fCheckDigit%( AccountNumber$ )                                        "
  28. ? "├───────────────────────────────────────────────────────────────────────"
  29. ? "│ PURPOSE: create/compute a check-digit for account numbers             "
  30. ? "│  PARAMS: ANo$  an account number string of no more than 10 characters "
  31. ? "│                preceding an optional '-' and containing no characters "
  32. ? "│                other than the 10 digits.                              "
  33. ? "├───────────────────────────────────────────────────────────────────────"
  34. ? "│ Check digits protect, primarily, from transposed figures more than    "
  35. ? "│ from total cases of dumb that seem to strike occasionally. Several    "
  36. ? "│ banks and credit unions use a system like this to protect, as much    "
  37. ? "│ as possible from these mistakes. As there are no hard and set rules   "
  38. ? "│ about where and how the check digits are attached to the account N°   "
  39. ? "│ but the norm is 12345-9 where the 9 is the check digit.               "
  40. ? "└───────────────────────────────────────────────────────────────────────"
  41. ?
  42.  
  43. AcctNo$ = "123456789-3" : GOSUB CKCKDIG
  44. AcctNo$ = "213456789-3" : GOSUB CKCKDIG
  45.  
  46. END
  47.  
  48. ' ───────────────────────────────────────────────────────────────
  49.  
  50. CKCKDIG:
  51.   PRINT AcctNo$;
  52.   IF VAL( RIGHT$( AcctNo$, 1 ) ) <> fCheckDigit%( AcctNo$ ) THEN
  53.       PRINT " HAS AN ERROR"
  54.     ELSE
  55.       PRINT " IS CORRECT"
  56.   END IF
  57.   PRINT
  58. RETURN